package com.mxpio.erp.common.inventory.entity;

import com.mxpio.erp.common.jpa.model.Notice;
import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Author : 吴盼盼
 * @Datetime : 2022/12/29 16:36
 * @Desc : 初始库存通知单
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INV_IS_NOTICE")
@Schema(description="初始库存通知单")
public class InitStockNotice extends Notice {
    private static final long serialVersionUID = 1L;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Transient
    private List<InitStockNoticeLine> initStockNoticeLines;

    @Override
    public String initTypeCode() {
        return "N01";
    }

    @Override
    public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
        InitStockNoticeLine noticeLine = new InitStockNoticeLine();
        noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
        noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
        noticeLine.setItemCode(orderExcuteVo.getItemCode());
        noticeLine.setNoticeNo(this.getNoticeNo());
        noticeLine.setQuantity(orderExcuteVo.getQuantity());
        noticeLine.setSort(orderExcuteVo.getSort());
        noticeLine.setLotNo(orderExcuteVo.getLotNo());
        noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
        return noticeLine;
    }

    @Override
    public List<? extends NoticeLine> getNoticeLines() {
        return this.initStockNoticeLines;
    }
}
